

package com.xtsoft.platform.base.system.domain;

/*
*    上海信拓信息技术有限公司  
*    Copyright (C) ShangHai XinTuo Software Inc.
*/

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xtsoft.core.entity.GenericEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.annotations.GenericGenerator;

import jakarta.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
 * SysTrade Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 * TODO: add class/table comments
 */
@Entity
@Table(name = "sys_trade")
@Data
public class SysTrade extends GenericEntity {


	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(name="sysTradeId",nullable=false,length=32)
    private String sysTradeId;


	/**
	*   
	*/
	@Column(name="descript",nullable=true, length=255 )
	private String descript;


	/**
	*   
	*/
	@Column(name="preSysTradeId",nullable=true, length=32 )
	private String preSysTradeId;


	/**
	*   
	*/
	@Column(name="state",nullable=true, length=10 )
	private Integer state;


	/**
	*   
	*/
	@Column(name="tradeName",nullable=false, length=128 )
	private String tradeName;


	@OneToMany(cascade={CascadeType.MERGE},fetch = FetchType.LAZY, mappedBy = "sysTrade")
	@JsonIgnore
	private List<SysOrganize> sysOrganizes = new ArrayList();
	
	public void addSysOrganize(SysOrganize sysOrganize){
		sysOrganizes.add(sysOrganize);
		sysOrganize.setSysTrade(this);
	}
	
	public void removeSysOrganize(SysOrganize sysOrganize){
		sysOrganize.setSysTrade(null);
		sysOrganizes.remove(sysOrganize);
	}
	

	/**
	*  默认构造
	*/
	public SysTrade(){
	
	}

	/**
	*  构造方法，自动测试使用，把除主键外的所有非空字段赋值
	*
	*  也可作普通使用  调用该构造方法时，字串参数填或不填均
	*  可，该带参构造方法仅为区别Lombok自动生成的默认构造方
	*  法。
	*  
	*  应用程序可根据需要修改该构造方法中的非空属性赋值。
	**/
	public SysTrade(String forAutoTest){

		this.tradeName = "New string";

	}

	/**
	 * @see Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("sysTradeId", this.sysTradeId) 
				.append("descript", this.descript) 
				.append("preSysTradeId", this.preSysTradeId) 
				.append("state", this.state) 
				.append("tradeName", this.tradeName) 
				.toString();
	}
	
	/**
	 * 以实体类主键生成HASHCODE
	 */
	@Override  
	public int hashCode() {  
	    return this.sysTradeId.hashCode();  
	} 	 
	
	/**
	 * 以实体类主键比较对象是否相等
	 */
	@Override  
	public boolean equals(Object obj) {  
	    if (obj instanceof SysTrade) {  
	        return this.sysTradeId.equals(((SysTrade) obj).getSysTradeId());  
	    }  
	    return false;  
	}	 
	
}
